<template>
  <div class="main">
    <div class="topbar bg-black py-2 px-3 d-flex ai-center">
      <img src="../assets/logo.png" height="30" />
      <div class="px-2 flex-1">
        <div class="text-white">王者荣耀</div>
        <div class="text-grey-1 fs-xx">团队成就更多</div>
      </div>
      <button type="button" class="btn bg-primary">立即下载</button>
    </div>
    <div class="bg-primary pt-3 pb-2">
      <div class="nav nav-inverse jc-around pb-1">
        <div class="nav-item" :class="{active: isActive === '1'}" @click="save(1)">
          <router-link class="nav-link" tag="div" to="/">首页</router-link>
        </div>
        <div class="nav-item" :class="{active: isActive === '2'}" @click="save(2)">
          <router-link class="nav-link" tag="div" to="/strategy">攻略中心</router-link>
        </div>
        <div class="nav-item" :class="{active: isActive === '3'}" @click="save(3)">
          <router-link class="nav-link" tag="div" to="/competition">赛事中心</router-link>
        </div>
        <div class="nav-item" :class="{active: isActive === '4'}" @click="save(4)">
          <router-link class="nav-link" tag="div" to="/game">IP新游</router-link>
        </div>
      </div>
    </div>

    <router-view />
  </div>
</template>

<script>
export default {
  name: "Home",
  components: {},
  data(){return {isActive:'1'}},
  watch:{
    isActive:{
      handler(n,o){
        if(n == 1){
          this.$router.push('/')
        }
        console.log(o)
      },
      immediate:true
    }
  },
  created(){
    
  },
  methods:{
    save(v){
      this.isActive = `${v}`
    }
  }
};
</script>

<style lang="scss">
@import '../assets/scss/_variable.scss';
  .topbar {
    // 有兼容性问题，部分老手机不支持
    position: sticky;
    top: 0;
    z-index: 999;
  }
</style>
